package doyouknow.group.CnAndZhb.service.impl;

import doyouknow.group.CnAndZhb.dao.fourth.HeartDetailDao;
import doyouknow.group.CnAndZhb.entity.HeartDetail;
import doyouknow.group.CnAndZhb.service.HeartDetailService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (HeartDetail)表服务实现类
 *
 * @author makejava
 * @since 2020-11-10 18:29:51
 */
@Service("heartDetailService")
public class HeartDetailServiceImpl implements HeartDetailService {
    @Resource
    private HeartDetailDao heartDetailDao;

    /**
     * 通过ID查询单条数据
     *
     * @param detailidx 主键
     * @return 实例对象
     */
    @Override
    public HeartDetail queryById(Integer detailidx) {
        return this.heartDetailDao.queryById(detailidx);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<HeartDetail> queryAllByLimit(int offset, int limit) {
        return this.heartDetailDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param heartDetail 实例对象
     * @return 实例对象
     */
    @Override
    public HeartDetail insert(HeartDetail heartDetail) {
        this.heartDetailDao.insert(heartDetail);
        return heartDetail;
    }

    /**
     * 修改数据
     *
     * @param heartDetail 实例对象
     * @return 实例对象
     */
    @Override
    public HeartDetail update(HeartDetail heartDetail) {
        this.heartDetailDao.update(heartDetail);
        return this.queryById(heartDetail.getDetailidx());
    }

    /**
     * 通过主键删除数据
     *
     * @param detailidx 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer detailidx) {
        return this.heartDetailDao.deleteById(detailidx) > 0;
    }
}